#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    cerr << s << endl;
    int n = s.size();
    bool flag = true;
    for (int i = 1;i < s.size();i++)
    {
        if (s[i] != s[i - 1])
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        cout << 0 << endl;
        return 0;
    }
    int left = 0, right = s.size() - 1;
    while (left < right)
    {
        if (s[left] != s[right])
        {
            cout << s.size() << endl;
            return 0;
        }
        ++left;
        --right;
    }
    cout << s.size() - 1 << endl;
    return 0;
}